class Solution {
public:
    int peakIndexInMountainArray(vector<int>& arr)
    {
        int lhs = 0, rhs = arr.size() - 1;
        int mid = lhs + (rhs - lhs + 1) / 2;

        while (lhs < rhs)
        {
            if (arr[mid] > arr[mid - 1]) lhs = mid;
            else rhs = mid - 1;

            mid = lhs + (rhs - lhs + 1) / 2;
        }

        return lhs;
    }
};